@import "../../styles/button";

.s-button {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 0;
  width: auto;
  font-weight: 400;
  text-align: center;
  vertical-align: middle;
  -webkit-appearance: none;
  -webkit-text-size-adjust: 100%;
  height: $button-default-height;
  line-height: $button-line-height;
  font-size: $font-size-large;
  transition: opacity $animation-duration-fast;
  border-radius: $button-border-radius;
  &::before {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    border: inherit;
    border-radius: inherit; /* inherit parent's border radius */
    transform: translate(-50%, -50%);
    opacity: 0;
    content: " ";
    background-color: $color-black;
    border-color: $color-black;
  }

  &::after {
    border-width: 0;
  }

  &--active::before {
    opacity: 0.05;
  }
  &--unclickable::after {
    display: none;
  }

  &--default {
    color: $button-default-color;
    background: $button-default-background-color;
    border: $button-border-width solid $button-default-border-color;
  }

  &--primary {
    color: $button-primary-color;
    background: $button-primary-background-color;
    border: $button-border-width solid $button-primary-border-color;
  }

  &--success {
    color: $button-success-color;
    background: $button-success-background-color;
    border: $button-border-width solid $button-success-border-color;
  }

  &--info {
    color: $button-info-color;
    background: $button-info-background-color;
    border: $button-border-width solid $button-info-border-color;
  }

  &--danger {
    color: $button-danger-color;
    background: $button-danger-background-color;
    border: $button-border-width solid $button-danger-border-color;
  }

  &--warning {
    color: $button-warning-color;
    background: $button-warning-background-color;
    border: $button-border-width solid $button-warning-border-color;
  }

  &--plain {
    background: $button-plain-background-color;
    &.s-button--primary {
      color: $button-primary-background-color;
    }

    &.s-button--success {
      color: $button-success-background-color;
    }

    &.s-button--info {
      color: $button-info-background-color;
    }

    &.s-button--danger {
      color: $button-danger-background-color;
    }

    &.s-button--warning {
      color: $button-warning-background-color;
    }
  }

  &--large {
    width: 100% !important;
    height: $button-large-height;
  }

  &--normal {
    padding: 0 32rpx;
    font-size: $button-normal-font-size;
  }

  &--small {
    min-width: $button-small-min-width;
    height: $button-small-height;
    padding: $padding-small;
    font-size: $button-small-font-size;
  }

  &--mini {
    display: inline-block;
    min-width: $button-mini-min-width;
    height: $button-mini-height;
    padding: 0 $padding-mini;
    font-size: $button-mini-font-size;
    & + .s-button--mini {
      margin-left: 5px;
    }
  }

  &--block {
    display: flex;
    width: 100% !important;
  }

  &--round {
    border-radius: $button-round-border-radius;
  }

  &--square {
    border-radius: 0;
  }

  &--disabled {
    opacity: $button-disabled-opacity;
    background: $button-disabled-background-color;
    border-color: $button-disabled-background-color;
  }

  &__text {
    display: inline;
  }

  &__loading-text,
  &__icon + &__text:not(:empty) {
    margin-left: $padding !important;
  }

  &__loading {
    display: inline-flex;
    justify-content: center;
    align-items: center;
  }

  &__icon {
    line-height: inherit !important;
    vertical-align: top;
  }
}
